using System;
using System.Runtime.CompilerServices;
using Engine;
using Pickle;

namespace Game
{
	public class LJMain : Mod
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class _003C_003Ec
		{
			public static readonly _003C_003Ec _003C_003E9 = new _003C_003Ec();

			public static Action _003C_003E9__2_1;

			public static Action _003C_003E9__2_2;

			public static Action _003C_003E9__2_3;

			internal void _003CPostInitialize_003Eb__2_1()
			{
				ModUtils.ReplaceScreen("Game", new LJGameScreen());
			}

			internal void _003CPostInitialize_003Eb__2_2()
			{
				ModUtils.ReplaceScreen("MainMenu", new LJMainMenuScreen());
			}

			internal void _003CPostInitialize_003Eb__2_3()
			{
				ModUtils.AddScreen("LJLoading", new LJGameLoadingScreen());
			}
		}

		public void Initialize()
		{
			Log.Information("Initializing LJAPI at frame " + Time.FrameIndex);
			NetworkManager.Start();
			Window.Closed += new Action(Dispose);
		}

		public void Dispose()
		{
			NetworkManager.Stop();
		}

		public void PostInitialize()
		{
			ModUtils.AddLoadAction(new Action(_003CPostInitialize_003Eb__2_0));
			ModUtils.AddLoadAction(_003C_003Ec._003C_003E9__2_1 ?? (_003C_003Ec._003C_003E9__2_1 = new Action(_003C_003Ec._003C_003E9._003CPostInitialize_003Eb__2_1)));
			ModUtils.AddLoadAction(_003C_003Ec._003C_003E9__2_2 ?? (_003C_003Ec._003C_003E9__2_2 = new Action(_003C_003Ec._003C_003E9._003CPostInitialize_003Eb__2_2)));
			ModUtils.AddLoadAction(_003C_003Ec._003C_003E9__2_3 ?? (_003C_003Ec._003C_003E9__2_3 = new Action(_003C_003Ec._003C_003E9._003CPostInitialize_003Eb__2_3)));
		}

		[CompilerGenerated]
		private void _003CPostInitialize_003Eb__2_0()
		{
			Log.AddLogSink(new DebugLogSink());
			ModUtils.AddDatabaseObjects(ModUtils.LoadXmlFromAssembly(this, "LJProject.xml"));
			ModUtils.ReplaceSubsystem(typeof(SubsystemViews), typeof(SubsystemLJViews), "RemotePlayers");
			ModUtils.AddSubsystemWithTemplate("GameProject", "RemotePlayers").SetNestedValue("HasAuthority", true);
			ModUtils.AddSubsystemWithTemplate("LJProject", "RemotePlayers").SetNestedValue("HasAuthority", false);
			ModUtils.AddSubsystem("GameProject", typeof(SubsystemRemoteEntities), "Players");
			ModUtils.AddSubsystem("LJProject", typeof(SubsystemRemoteEntities), "Players");
			ModUtils.AddSubsystem("GameProject", typeof(SubsystemRemoteTransmitter), "SubsystemRemoteEntities, RemotePlayers").SetNestedValue("IsClient", false);
			ModUtils.AddSubsystem("LJProject", typeof(SubsystemRemoteTransmitter), "SubsystemRemoteEntities, RemotePlayers").SetNestedValue("IsClient", true);
		}
	}
}
